package com.cennavi.funcs;

import org.apache.spark.api.java.function.Function2;

import scala.Tuple2;

/** * @author  作者 :allen
    * @date 创建时间：2017年11月15日 下午7:47:47 
    * @version 1.0 
    */

public class GetAllTimeFunction 
	implements Function2<Tuple2<String, String>, Tuple2<String, String>, Tuple2<String, String>> {

	private static final long serialVersionUID = 1L;

	public Tuple2<String, String> call(Tuple2<String, String> arg0, Tuple2<String, String> arg1) throws Exception {
		// 把window中的所有数据逐条对比，保留每次对比中较大的时间
		String time1;
		String time2;
		if(arg0._2.split(",").length < 4){
			time1 = arg0._2;
		}else{
			time1 = arg0._2.split(",")[3];			
		}
		if(arg1._2.split(",").length < 4){
			time2 = arg1._2;
		}else{
			time2 = arg1._2.split(",")[3];
		}
		Tuple2<String, String> timeAfterCompare;
		timeAfterCompare = new Tuple2<String, String>("allTime", time1 + "|" + time2);
		return timeAfterCompare;
	}

}
